using System;

namespace HelloWorld.Learn
{
    public class Celsius
    {
        public Celsius(float temp)
        {
            Degrees = temp;
        }
        
        public float Degrees { get; }
        
        public static explicit operator Fahrenheit(Celsius c)
        {
            return new Fahrenheit((9.0f / 5.0f) * c.Degrees + 32);
        }
    }

    public class Fahrenheit
    {
        public Fahrenheit(float temp)
        {
            Degrees = temp;
        }
        
        public float Degrees { get; }
        
        public static explicit operator Celsius(Fahrenheit fahr)
        {
            return new Celsius((5.0f / 9.0f) * (fahr.Degrees - 32));
        }
    }

    public class ExplicitDemo
    {
        public static void Demo()
        {
            var f = new Fahrenheit(100.0f);
            Console.Write($"{f.Degrees} Fahrenheit");

            Celsius c = (Celsius)f;
            Console.Write($" = {c.Degrees} Celsius");

            Fahrenheit f2 = (Fahrenheit)c;
            Console.WriteLine($" = {f2.Degrees} Fahrenheit");
        }
    }
}
